package com.goodving.guli.activity;

import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.os.Process;
import android.view.KeyEvent;

import com.goodving.guli.R;
import com.goodving.guli.utility.C1076y;
import com.goodving.guli.utility.GuliActivityLifecycleCallbacks;
import com.goodving.guli.utility.C1465g;
import com.goodving.guli.utility.C1478r;
import com.goodving.guli.utility.C1479s;
import com.goodving.guli.utility.C1481u;
import com.goodving.guli.utility.ej;

import java.util.List;

/**
 * Created by Administrator on 2015-11-17.
 */
public class SplashScreenActivity extends C1076y {
    private final int f4307q;

    public SplashScreenActivity() {
        this.f4307q = 2000;
    }

    protected void onPause() {
        super.onPause();

    }

    protected void onResume() {
        super.onResume();

    }

    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(R.layout.activity_splashscreen);
        m8075k();
    }

    private void m8075k() {


        m8076l();
        C1479s.m12051a(new ej(this));
        new Handler().postDelayed(new ek(this), GuliActivityLifecycleCallbacks.delayTime);
    }

    private void m8076l() {
        SharedPreferences.Editor edit = C1481u.m12082d().edit();
        Intent intent = getIntent();
        String stringExtra = intent.getStringExtra("from");
        if (stringExtra != null) {
            edit.putInt(C1465g.bq, 1).commit();
            if (stringExtra.equals("qqhealth")) {
                stringExtra = intent.getStringExtra("accesstoken");

                String stringExtra3 = intent.getStringExtra("accesstokenexpiretime");
                edit.putString("from", "qqhealth");
                edit.putString("accesstoken", stringExtra);

                edit.putString("accesstokenexpiretime", stringExtra3);
                edit.commit();
                return;
            }
            return;
        }
        edit.putInt(C1465g.bq, 0).commit();
    }

    class ek implements Runnable {
        final /* synthetic */ SplashScreenActivity f4528a;

        ek(SplashScreenActivity splashScreenActivity) {
            this.f4528a = splashScreenActivity;
        }

        public void run() {
            this.f4528a.m8077m();
        }
    }

    private void m8077m() {
        Class cls;
        Intent intent = new Intent();
        switch (C1481u.m12082d().getInt(C1465g.cc, 0)) {
//            case 0 /*0*/:
//                cls = WelcomePageActivity.class;
//                break;
//            case 1 /*1*/:
//                cls = LoginFragmentActivity.class;
//                intent.putExtra(C1465g.bX, 0);
//                break;
//            case 2 /*2*/:
//                cls = SettingUserInfoActivity.class;
//                intent.putExtra(C1465g.bH, true);
//                break;
//            case 3 /*3*/:
//                cls = SettingUserGoalActivity.class;
//                intent.putExtra(C1465g.bH, true);
//                break;
            default:
                Intent intent2 = getIntent();
                if (intent2.getExtras() != null) {
                    String stringExtra = intent2.getStringExtra(C1465g.cl);
                    String stringExtra2 = intent2.getStringExtra(C1465g.cm);
                    if (!C1478r.m12046a(stringExtra)) {
                        intent.putExtra(C1465g.cl, stringExtra);
                    }
                    if (!C1478r.m12046a(stringExtra2)) {
                        intent.putExtra(C1465g.cm, stringExtra2);
                    }
                }
                cls = MainFragmentActivity.class;
                break;
        }
        intent.setClass(this, cls);
        startActivity(intent);
        finish();
        overridePendingTransition(17432576, 17432577);
    }

    public void onBackPressed() {
    }

    public boolean onKeyDown(int i, KeyEvent keyEvent) {
        switch (i) {
            case 4 /*4*/:
                finish();
                break;
        }
        return super.onKeyDown(i, keyEvent);
    }

    private boolean m8078n() {
        List<ActivityManager.RunningAppProcessInfo> runningAppProcesses = ((ActivityManager) getSystemService(Context.ACTIVITY_SERVICE)).getRunningAppProcesses();
        String packageName = getPackageName();
        int myPid = Process.myPid();
        for (ActivityManager.RunningAppProcessInfo runningAppProcessInfo : runningAppProcesses) {
            if (runningAppProcessInfo.pid == myPid && packageName.equals(runningAppProcessInfo.processName)) {
                return true;
            }
        }
        return false;
    }
}
